dat <- read.csv("../result/wgt_x.csv")
wx = dat$w_ols[dat$x>8]
sx = dat$w_ols_se[dat$x>8]
wz = dat$w_iv[dat$x>8]
sz = dat$w_iv_se[dat$x>8]

hx = wx + sx
lx = wx - sx
hz = wz + sz
lz = wz - sz

uni = 0.1
high <- max( max(wx),max(hz) )
high <- ceiling(high/uni)*uni
low  <- min( min(wx),min(lz) ) 
low <- floor(low/uni)*uni
scales= round( seq(low,high,by=uni),digits=2 )
eps = 0.1
eta = 0.25

xx = 9:18
#xone = 7:19
#yone = rep(1,times=13)
xl = c(0,20)
yl = c(-0.10,0.30)
pdf('../result/wgt_coll.pdf')
par(mar=c(6.1,5.3,2.1,2.1),mgp=c(4.5,1,0),las=1)
plot(xx,wz,type="o",lwd=1.5,cex=1.75,lty=2,pch=16,col='#e31a1c',ylim=yl,xlim=xl,xlab="",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
plot(xx,wx,type="o",lwd=1.5,cex=1.75,lty=2,pch=17,ylim=yl,xlim=xl,xlab="Years of education",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
segments(xx,lz,xx,hz,lwd=1.5,col='#e31a1c')
segments(xx-eps,lz,xx+eps,lz,lwd=1.5,col='#e31a1c')
segments(xx-eps,hz,xx+eps,hz,lwd=1.5,col='#e31a1c')
par(new=T,las=1)
abline(h=0,lty=3,lwd=3.0)
par(new=T,las=1)
#abline(v=12,lty=3,lwd=3.0) # high school completion (11->12)
#par(new=T,las=1)
#abline(v=16,lty=3,lwd=3.0) # college completion (15->16)
#par(new=T,las=1)
axis(1, at=c(0,4,8,12,16,20), cex.axis=1.6)
axis(2, at=scales, cex.axis=1.6, lab=format(scales,nsmall=0) )
dev.off()